﻿Imports System.Data
Partial Class Login
    Inherits System.Web.UI.Page

    Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
        lblErr.Visible = False
        Dim bbl As OAMS.BBL.UsersBBL = New OAMS.BBL.UsersBBL()
        Dim dao As OAMS.DAO.UsersDAO = New OAMS.DAO.UsersDAO("pdduiiDB")
        Dim dt As DataTable = bbl.GetEmpData(txtUserID.Text, "LungParkDB")
        If dt.Rows.Count = 0 Then
            lblErr.Visible = True
            Exit Sub
        End If
        Dim cryObj As Creasys.Utility.DesEncrypt = New Creasys.Utility.DesEncrypt()
        '  Dim pass As String = cryObj.EncryptString(txtPassword.Text.Trim, "12345678")
        Dim pass As String = txtPassword.Text.Trim

        If dt.Rows(0)("Password").ToString.Trim <> pass Then
            lblErr.Visible = True
            Exit Sub
        End If



        Session("UID") = dt.Rows(0)("emp_no").ToString
        Session("UserName") = dt.Rows(0)("emp_name").ToString
        Session("ActualUID") = dt.Rows(0)("emp_no").ToString
        Session("ActualUserName") = dt.Rows(0)("emp_name").ToString
        Session("dbName") = "LungParkDB"

        Session("GlobalLanguage") = bbl.GetLanguage(Session("ActualUID").ToString(), Session("dbName").ToString)
        Session("Theme") = bbl.GetTheme(Session("ActualUID").ToString(), Session("dbName").ToString)
        Session("MenuCollapsible") = bbl.GetMenuCollapsible(Session("ActualUID").ToString(), Session("dbName").ToString)
        Session("WinTargetBlank") = bbl.GetWinTargetBlank(Session("ActualUID").ToString(), Session("dbName").ToString)
        Response.Redirect("~/Webform/Main/Mainpage.aspx")
    End Sub
End Class
